jquery教程

推荐列表 站点导航

当前位置:首页 > jquery > jquery教程 >

jcrop基本参数一览

来源:网络整理  作者:fen  发布时间:2020-12-25 10:31
Jcrop是基于JQuery的图片裁剪插件,这里简单介绍下基本参数,需要的朋友可以参考下...

<link href="css/jquery.Jcrop.css">
<script src="http://www.dismall.com/thread-957-1-1.html/a_5756/js/jquery.js"></script>
<script src="http://www.dismall.com/thread-957-1-1.html/a_5756/js/jquery.Jcrop.js"></script>

二、在head部分插入回调函数等相关处理参数。

复制代码 代码如下:


<script language="Javascript">
  <!--
  jQuery(function($){
 // Create variables (in this scope) to hold the API and image size
  var jcrop_api, boundx, boundy;

  $('#cropbox').Jcrop({
  minSize: [0,0],
  maxSize:[0,0],
  setSelect: [0,0,0,0],
  boxWidth:800,
  borderOpacity:0.3,
  keySupport:false,
  dragEdges:false,
  allowSelect:false,
  allowResize:false,
  bgOpacity:0.2,
  boundary:0,
  //allowMove:false,
  addClass: 'jcrop-handle',
  onSelect: updateCoords,
  },
  function(){
  // Use the API to get the real image size
  var bounds = this.getBounds();
  boundx = bounds[0];
  boundy = bounds[1];
  // Store the API in the jcrop_api variable
  jcrop_api = this;
  });
  function updateCoords(c)
  {
  $('#x').val(c.x);
  $('#y').val(c.y);
  $('#w').val(c.w);
  $('#h').val(c.h);
  };
  function checkCoords()
  {
  if (parseInt($('#w').val())) return true;
  alert('请选择裁剪区域');
  return false;
  };
  });
-->
</script>

三、给相关图片加上id以便识别。

<img src="http://www.dismall.com/thread-957-1-1.html/a_5756/x.jpg">
这样就能实现最简单的裁剪效果,至于如何结合php等动态语句处理图片,在置顶的文章里已经给出了示例。

下表给出基本options参数设置:

名称 默认值 说明 allowSelect true 允许新选框 allowMove true 允许选框移动 allowResize true 允许选框缩放 trackDocument true baseClass "jcrop" 基础样式名前缀。说明:class="jcrop-holder",更改的只是其中的 jcrop。 addClass null 添加样式会。例:假设值为 "test",那么会添加样式到 bgColor "black" 背景颜色。颜色关键字、HEX、RGB 均可。 bgOpacity 0.6 背景透明度 bgFade false 使用背景过渡效果 borderOpacity 0.4 选框边框透明度 handleOpacity 0.5 缩放按钮透明度 handleSize 9 缩放按钮大小 handleOffset 5 缩放按钮与边框的距离 aspectRatio 0 选框宽高比。说明:width/height keySupport true 支持键盘控制。按键列表:上下左右(移动)、Esc(取消)、Tab(跳出裁剪框,到下一个) cornerHandles true 允许边角缩放 sideHandles true 允许四边缩放 drawBorders true 绘制边框 dragEdges true 允许拖动边框 fixedSupport true touchSupport null boxWidth 0 画布宽度 boxHeight 0 画布高度 boundary 2 边界。说明:可以从边界开始拖动鼠标选择裁剪区域 fadeTime 400 过度效果的时间 animationDelay 20 动画延迟 swingSpeed 3 过渡速度 minSelect [0,0] 选框最小选择尺寸。说明:若选框小于该尺寸,则自动取消选择 maxSize [0,0] 选框最大尺寸 minSize [0,0] 选框最小尺寸 onChange function(){} 选框改变时的事件 onSelect function(){} 选框选定时的事件 onRelease function(){} 取消选框时的事件

下表是api方法

名称 说明 setImage(string) 设定(或改变)图像。例:jcrop_api.setImage("newpic.jpg") setOptions(object) 设定(或改变)参数,格式与初始化设置参数一样 setSelect(array) 创建选框,参数格式为:[x,y,x2,y2] animateTo(array) 用动画效果创建选框,参数格式为:[x,y,x2,y2] release() 取消选框 disable() 禁用 Jcrop。说明:已有选框不会被清除。 enable() 启用 Jcrop destroy() 移除 Jcrop tellSelect() 获取选框的值(实际尺寸)。例子:console.log(jcrop_api.tellSelect()) tellScaled() 获取选框的值(界面尺寸)。例子:console.log(jcrop_api.tellScaled()) getBounds() 获取图片实际尺寸,格式为:[w,h] getWidgetSize() 获取图片显示尺寸,格式为:[w,h] getScaleFactor() 获取图片缩放的比例,格式为:[w,h]

相关热词:

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!

本文地址: https://v30.fanwenzhu.com/jq/jc/8868.shtml

相关文章
最新文章
PHP识别相片是否是颠倒的 PHP识别相片是否是颠倒的

时间:2020-12-28

python编程有哪些ide python编程有哪些ide

时间:2020-12-28

python开发工程师是做什么 python开发工程师是做什么

时间:2020-12-28

php构造函数的作用 php构造函数的作用

时间:2020-12-28

php怎么跟数据库连接 php怎么跟数据库连接

时间:2020-12-28

php实现顺序线性表 php实现顺序线性表

时间:2020-12-28

Python多重继承中的菱形继 Python多重继承中的菱形继

时间:2020-12-28

php中break的作用 php中break的作用

时间:2020-12-28

Copyright © www.juheyunku.com      关于 | 合作 | 声明 | 联系 | 更新 | 地图 | Tags

jcrop基本参数一览

2020-12-25 编辑:fen

<link href="css/jquery.Jcrop.css">
<script src="http://www.dismall.com/thread-957-1-1.html/a_5756/js/jquery.js"></script>
<script src="http://www.dismall.com/thread-957-1-1.html/a_5756/js/jquery.Jcrop.js"></script>

二、在head部分插入回调函数等相关处理参数。

复制代码 代码如下:


<script language="Javascript">
  <!--
  jQuery(function($){
 // Create variables (in this scope) to hold the API and image size
  var jcrop_api, boundx, boundy;

  $('#cropbox').Jcrop({
  minSize: [0,0],
  maxSize:[0,0],
  setSelect: [0,0,0,0],
  boxWidth:800,
  borderOpacity:0.3,
  keySupport:false,
  dragEdges:false,
  allowSelect:false,
  allowResize:false,
  bgOpacity:0.2,
  boundary:0,
  //allowMove:false,
  addClass: 'jcrop-handle',
  onSelect: updateCoords,
  },
  function(){
  // Use the API to get the real image size
  var bounds = this.getBounds();
  boundx = bounds[0];
  boundy = bounds[1];
  // Store the API in the jcrop_api variable
  jcrop_api = this;
  });
  function updateCoords(c)
  {
  $('#x').val(c.x);
  $('#y').val(c.y);
  $('#w').val(c.w);
  $('#h').val(c.h);
  };
  function checkCoords()
  {
  if (parseInt($('#w').val())) return true;
  alert('请选择裁剪区域');
  return false;
  };
  });
-->
</script>

三、给相关图片加上id以便识别。

<img src="http://www.dismall.com/thread-957-1-1.html/a_5756/x.jpg">
这样就能实现最简单的裁剪效果,至于如何结合php等动态语句处理图片,在置顶的文章里已经给出了示例。

下表给出基本options参数设置:

名称 默认值 说明 allowSelect true 允许新选框 allowMove true 允许选框移动 allowResize true 允许选框缩放 trackDocument true baseClass "jcrop" 基础样式名前缀。说明:class="jcrop-holder",更改的只是其中的 jcrop。 addClass null 添加样式会。例:假设值为 "test",那么会添加样式到 bgColor "black" 背景颜色。颜色关键字、HEX、RGB 均可。 bgOpacity 0.6 背景透明度 bgFade false 使用背景过渡效果 borderOpacity 0.4 选框边框透明度 handleOpacity 0.5 缩放按钮透明度 handleSize 9 缩放按钮大小 handleOffset 5 缩放按钮与边框的距离 aspectRatio 0 选框宽高比。说明:width/height keySupport true 支持键盘控制。按键列表:上下左右(移动)、Esc(取消)、Tab(跳出裁剪框,到下一个) cornerHandles true 允许边角缩放 sideHandles true 允许四边缩放 drawBorders true 绘制边框 dragEdges true 允许拖动边框 fixedSupport true touchSupport null boxWidth 0 画布宽度 boxHeight 0 画布高度 boundary 2 边界。说明:可以从边界开始拖动鼠标选择裁剪区域 fadeTime 400 过度效果的时间 animationDelay 20 动画延迟 swingSpeed 3 过渡速度 minSelect [0,0] 选框最小选择尺寸。说明:若选框小于该尺寸,则自动取消选择 maxSize [0,0] 选框最大尺寸 minSize [0,0] 选框最小尺寸 onChange function(){} 选框改变时的事件 onSelect function(){} 选框选定时的事件 onRelease function(){} 取消选框时的事件

下表是api方法

名称 说明 setImage(string) 设定(或改变)图像。例:jcrop_api.setImage("newpic.jpg") setOptions(object) 设定(或改变)参数,格式与初始化设置参数一样 setSelect(array) 创建选框,参数格式为:[x,y,x2,y2] animateTo(array) 用动画效果创建选框,参数格式为:[x,y,x2,y2] release() 取消选框 disable() 禁用 Jcrop。说明:已有选框不会被清除。 enable() 启用 Jcrop destroy() 移除 Jcrop tellSelect() 获取选框的值(实际尺寸)。例子:console.log(jcrop_api.tellSelect()) tellScaled() 获取选框的值(界面尺寸)。例子:console.log(jcrop_api.tellScaled()) getBounds() 获取图片实际尺寸,格式为:[w,h] getWidgetSize() 获取图片显示尺寸,格式为:[w,h] getScaleFactor() 获取图片缩放的比例,格式为:[w,h]

本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供学习参考!
本文地址为 https://v30.fanwenzhu.com/jq/jc/8868.shtml

相关文章

风云图片

推荐阅读

返回jquery教程频道首页